/**
 *
 */
import Util;
import OpenApi;

import EndpointUtil;

extends OpenApi;


init(config: OpenApi.Config){
  super(config);
  @endpointRule = '';
  
  checkConfig(config);
  @endpoint = getEndpoint('nbf-vpc-cloud', @regionId, @endpointRule, @network, @suffix, @endpointMap, @endpoint);
}

function getEndpoint(productId: string, regionId: string, endpointRule: string, network: string, suffix: string, endpointMap: map[string]string, endpoint: string) throws: string{
  if (!Util.empty(endpoint)) {
    return endpoint;
  }
  
  if (!Util.isUnset(endpointMap) && !Util.empty(endpointMap[regionId])) {
    return endpointMap[regionId];
  }
  return EndpointUtil.getEndpointRules(productId, regionId, endpointRule, network, suffix);
}

model AdadaAResponseBody = {
  errorCode?: string(name='errorCode'),
  errorMsg?: string(name='errorMsg'),
  result?: string(name='result'),
  success?: boolean(name='success'),
}

model AdadaAResponse = {
  headers?: map[string]string(name='headers'),
  statusCode?: int32(name='statusCode'),
  body?: AdadaAResponseBody(name='body'),
}

async function adadaAWithOptions(headers: map[string]string, runtime: Util.RuntimeOptions): AdadaAResponse {
  var req = new OpenApi.OpenApiRequest{ 
    headers = headers,
  };
  var params = new OpenApi.Params{
    action = 'AdadaA',
    version = '2021-11-15_13-11-23-360',
    protocol = 'HTTP',
    pathname = `/caihe_cloud_product_1/1_0_0/adadaA`,
    method = 'POST',
    authType = 'AK',
    style = 'ROA',
    reqBodyType = 'json',
    bodyType = 'json',
  };
  return callApi(params, req, runtime);
}

async function adadaA(): AdadaAResponse {
  var runtime = new Util.RuntimeOptions{};
  var headers : map[string]string = {};
  return adadaAWithOptions(headers, runtime);
}

model YxTestApiResponseBody = {
  errorCode?: string(name='errorCode'),
  errorMsg?: string(name='errorMsg'),
  result?: string(name='result'),
  success?: boolean(name='success'),
}

model YxTestApiResponse = {
  headers?: map[string]string(name='headers'),
  statusCode?: int32(name='statusCode'),
  body?: YxTestApiResponseBody(name='body'),
}

async function yxTestApiWithOptions(headers: map[string]string, runtime: Util.RuntimeOptions): YxTestApiResponse {
  var req = new OpenApi.OpenApiRequest{ 
    headers = headers,
  };
  var params = new OpenApi.Params{
    action = 'YxTestApi',
    version = '2021-11-15_13-11-23-360',
    protocol = 'HTTPS',
    pathname = `/caihe_cloud_product_1/1_0_0/yxTestApi`,
    method = 'POST',
    authType = 'AK',
    style = 'ROA',
    reqBodyType = 'json',
    bodyType = 'json',
  };
  return callApi(params, req, runtime);
}

async function yxTestApi(): YxTestApiResponse {
  var runtime = new Util.RuntimeOptions{};
  var headers : map[string]string = {};
  return yxTestApiWithOptions(headers, runtime);
}

